package org.examples;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@EnableDiscoveryClient
@RefreshScope
@RestController
public class ConfigClientApplication {

    @Value("${user.name}")
    private String userName ;

    @Value("${user.age}")
    private Integer userAge ;

    public static void main(String[] args) {
        SpringApplication.run(ConfigClientApplication.class,args) ;
    }

    //获取配置文件里面用户的信息
    @GetMapping("/user/info")
    public ResponseEntity<String> getUser(){
        return ResponseEntity.ok(String.format("从配置中心获取的信息为：user：%s，age：%s",userName,userAge)) ;
    }
}
